

$(function(){
	//1.tab_wrapper 组件切换
	tab_nav();
	function tab_nav(){
		var $tab_nav = $('.tab-wrapper .tab-nav');
		$tab_nav.on('click',function(e){
			$tab_nav.removeClass('active');
			$(this).addClass('active');
		});
	}
	
	
	
	//2.下拉列表
	var firstOff = secondOff = true;
	select_wrapper('.tran-type',firstOff);
	if($('.tran-stage').length>0){
		select_wrapper('.tran-stage',secondOff);
	}
	function select_wrapper(sel,selOff){
		var $select_wrapper = $(sel+' .select'),
			$select_input = $(sel+' input'),
			$select_list = $(sel+' .select_list'),
			$select_li = $(sel+' .li');
		$select_wrapper.click(function(e){
			
			//收起其他下拉选择
			
			if(selOff){
				selectOff = false;
				$(this).addClass('active');
				$select_list.slideDown();
				
				if($select_li.length>=5){
					scroll(sel+' .select_list');
				}
			}else{
				selOff = true;
				$(this).removeClass('active');
				$select_list.slideUp();
			}
			e.stopPropagation();
		});
		
		//选中下拉列表中选项
		$select_li.click(function(e){
			selOff = true;
			//标记选中
			$select_li.removeClass('selected');
			$(this).addClass('selected');
			
			$select_wrapper.removeClass('active');
			$select_input.val($(this).text());
			
			$select_list.slideUp();
			e.stopPropagation();
		});
		
		
		//收起下拉列表
		$(document).click(function(){
			selOff = true;
			$select_list.slideUp();
			$select_wrapper.removeClass('active');
		});
		$(document).scroll(function(){
			selOff = true;
			$select_list.slideUp();
			$select_wrapper.removeClass('active');
		});
	}
	
	
	//3.日期选择
	if($("#datatime").length>0){
		$("#datatime").jeDate({
			range:' 至 ',
			minDate: '1970-01',
	    	maxDate:  $.nowDate(),
	        format: "YYYY-MM",
	    });
	    $('#datatime').on('click',function(){
	    	firstOff = secondOff = true;
			$('.tran-select .select').removeClass('active');
			$('.tran-select .select_list').slideUp();
	    });
	}
    
    
    if($('.search-wrapper .setbtn').length > 0){
    	//4.收起赛选条件
    	$('.search-wrapper .setbtn').on('click',function(){
    		$(this).toggleClass('active');
    		$('.search-bottom').slideToggle();
    	});
    }
});
